<?php
class PostProductAction extends UserAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'tpl';
		$this->layout = 'index';
		$this->data['menu']		= 'post';
	}

	public function execute()
	{
		$id				= $this->context->get('id');
		if(is_numeric($id) && $id)
		{
			$postService		= new PostService();
			$this->data['info']	= $postService->get($id);
			if($this->data['info']['user_id']!=$this->data['user']['id'])
			{
				header('Location:'.$this->data['cf']->getLoginUrl());
				return;
			}
		}
		else
		{
			$url			= base64_decode($this->context->get('url'));
			if($url!='')
			{
				$productId	= $this->getProductIdFromUrl($url);
				if($productId>0)
				{
					$productInfo	= C('ProductService')->getProductById($productId);
					if($productInfo)
					{
						$this->data['info']['title']	= $productInfo['item']['title'];
					}
				}
				$this->data['info']['content']['url']	= $url;
			}
		}
		
		$seoTitle		= '分享商品';
		if($id>0)
		{
			$seoTitle	= '编辑帖子：'.$this->data['info']['title'];
		}
		$seoTitle		.= '-'.$this->data['site']['site_name'];
		$this->data['seo']['title']			= $seoTitle;
	}
}
